package com.gxc.healthfood.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxc.healthfood.entity.FoodNutrients;
import com.gxc.healthfood.service.FoodNutrientsService;
import com.gxc.healthfood.mapper.FoodNutrientsMapper;
import org.springframework.stereotype.Service;

/**
* @author hasee
* @description 针对表【food_nutrients】的数据库操作Service实现
* @createDate 2025-10-03 16:14:50
*/
@Service
public class FoodNutrientsServiceImpl extends ServiceImpl<FoodNutrientsMapper, FoodNutrients>
    implements FoodNutrientsService{

    /**
     * 根据食物ID获取营养成分
     * @param foodId 食物ID
     * @return 营养成分实体
     */
    @Override
    public FoodNutrients getByFoodId(Long foodId) {
        QueryWrapper<FoodNutrients> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("food_id", foodId);
        return getOne(queryWrapper);
    }
}




